using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using SpoonCore2.Message.Header;

namespace SpoonCore2.Message.Header.Option
{
	class AcknowledgmentOption : IMessageOption
	{
		public enum AcknowledgType : byte { Request, Response }

		private static readonly Random _rand = new Random();
		private int _seqId = _rand.Next();
		private AcknowledgType _type = AcknowledgType.Request;

		public byte Id
		{
			get { return 1; }
		}

		public int SeqId
		{
			get { return _seqId; }
			set { _seqId = value; }
		}

		public AcknowledgType Type
		{
			get { return _type; }
			set { _type = value; }
		}

		public void GetBytes(BinaryWriter bw)
		{
			bw.Write(SeqId);
			bw.Write((byte)Type);
		}

		public void SetBytes(BinaryReader br)
		{
			SeqId = br.ReadInt32();
			Type = (AcknowledgType)br.ReadByte();
		}
	}
}